package com.framwork.core.api.addressbook.dept.input;

import com.alibaba.fastjson.JSONObject;
import com.framwork.core.base.AbstractAPIInput;
import com.framwork.core.base.em.RequestMappering;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * @author ：james.liu
 * @date ：Created in 2022/3/8 16:12
 * @description：
 * @version: 1.0
 */
public class OpenApisContactV3DepartmentsSearchInput extends AbstractAPIInput {

    private String query;

    public String getQuery() {
        return query;
    }

    public void setQuery(String query) {
        this.query = query;
    }

    public final String toBody(OpenApisContactV3DepartmentsSearchInput input) {
        if (Objects.isNull(input)) {
            return null;
        }
        JSONObject r = new JSONObject();
        if (StringUtils.isNotBlank(input.getQuery())) {
            r.put("query", input.getQuery());
        }
        return r.toJSONString();
    }

    /**
     * 定义路径
     */
    public final void eventCmd() {
        String format = RequestMappering.open_apis_contact_v3_departments_search.getMapperName();
        if (StringUtils.isNotBlank(this.getUserIdType())) {
            format = format + "?user_id_type=" + this.getUserIdType();
        }
        if (StringUtils.isNotBlank(this.getDepartmentIdType())) {
            format = format + "&department_id_type=" + this.getDepartmentIdType();
        }
        if (Objects.nonNull(this.getPageSize())) {
            format = format + "&page_size=" + this.getPageSize();
        }
        if (StringUtils.isNotBlank(this.getPageToken())) {
            format = format + "&page_token=" + this.getPageToken();
        }
        this.setCmdId(format);
    }
}
